# Copyright 2020 The Magma Authors.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[Unit]
Description=Magma %i service using Docker Compose
Requires=docker.service
After=docker.service

[Service]
Type=simple
WorkingDirectory={{ working_dir }}
Environment=DOCKER_REGISTRY={{ registry_url }}
Environment=IMAGE_VERSION={{ image_version }}

{{ systemd_extra }}

ExecStartPre=/usr/local/bin/docker-compose rm -fsv
ExecStart=/usr/local/bin/docker-compose {{ systemd_start_args_pre }} up {{ systemd_start_args_post }}
ExecStop=/usr/local/bin/docker-compose down {{ systemd_stop_args }}
Restart=always
# Use docker logging framework for the container logs
StandardOutput={{ systemd_stdout }}
StandardError={{ systemd_stderr }}
SyslogIdentifier=%i

[Install]
WantedBy=multi-user.target
